package com.fitso.wicket.validation;

import java.io.Serializable;
import java.util.regex.Pattern;

import org.apache.wicket.validation.validator.PatternValidator;

public class PasswordValidator extends PatternValidator implements Serializable {
	// Only change on breaking changes, i.e., removing fields
	private static final long serialVersionUID = 1L;

	/** singleton instance */
	private static final PasswordValidator INSTANCE = new PasswordValidator();

	/**
	 * Retrieves the singleton instance of <code>PasswordValidator</code>.
	 * 
	 * @return the singleton instance of <code>PasswordValidator</code>
	 */
	public static PasswordValidator getInstance() {
		return INSTANCE;
	}

	/**
	 * ( # Start of group (?=.*\d) # must contains one digit from 0-9
	 * (?=.*[a-z]) # must contains one lowercase characters (?=.*[A-Z]) # must
	 * contains one uppercase characters (?=.*[@#$%]) # must contains one
	 * special symbols in the list "@#$%" . # match anything with previous
	 * condition checking {8,20} # length at least 6 characters and maximum of
	 * 20 ) # End of group
	 */
	protected PasswordValidator() {
		super("((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})", Pattern.CASE_INSENSITIVE);
	}
}
